package com.blue.controller;

import com.blue.mapper.UserMapper;
import com.blue.pojo.Result;
import com.blue.pojo.User;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RestController
public class UserController {
    @Autowired
    private UserMapper userMapper;

    @GetMapping("/user/{id}")
    public Result getUserById(@PathVariable Long id) {
        User user = userMapper.selectUserById(id);
        return Result.ok("查询成功!", user);
    }

    @GetMapping("/users")
    public Result getAllUser() {
        List<User> users = userMapper.selectAllUser();
        return Result.ok("查询成功!", users);
    }
}
